﻿je_sick_man_main = {
	icon = "gfx/interface/icons/event_icons/event_skull.dds"

	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
		}
	}

	on_complete = {
		remove_modifier = sick_man_of_europe
		trigger_event = {
			id = sick_man.2
		}
	}

	timeout = 8030

	on_timeout = {
		remove_modifier = sick_man_of_europe
		trigger_event = {
			id = sick_man.3
		}
	}

	current_value = {
		value = var:sick_man_var
	}

	goal_add_value = {
		add = 4
	}

	progressbar = yes

	weight = 10000
	should_be_pinned_by_default = yes
}

je_sick_man_macedonia = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"

	complete = {
		owns_entire_state_region = STATE_SKOPIA
        owns_entire_state_region = STATE_MACEDONIA
		owns_entire_state_region = STATE_WESTERN_THRACE
		owns_entire_state_region = STATE_NORTHERN_THRACE
		owns_entire_state_region = STATE_BULGARIA
	}

	on_complete = {
		custom_tooltip = je_sick_man_advance
		change_variable = {
			name = sick_man_var
			add = 1
		}
		set_variable = completed_sick_man_macedonia_je

        add_journal_entry = {
            type = je_sick_man_albania
        }
	}

	invalid = {
		custom_tooltip = {
			text = finished_sick_man_tt
			has_variable = sick_man_complete
		}
	}

	inheritable = no

	weight = 5000
}

je_sick_man_albania = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"

	complete = {
		OR = {
			AND = {
				exists = c:ALB
				c:ALB = {
					is_subject_of = ROOT
				}
			}
			AND = {
				owns_entire_state_region = STATE_ALBANIA
			}
		}
	}

	on_complete = {
		custom_tooltip = je_sick_man_advance
		change_variable = {
			name = sick_man_var
			add = 1
		}
		set_variable = completed_sick_man_albania_je
	}

	invalid = {
		custom_tooltip = {
			text = finished_sick_man_tt
			has_variable = sick_man_complete
		}
	}

	inheritable = no

	weight = 5000
}

je_sick_man_iraq = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"
	
	complete = {
		OR = {
			AND = {
				exists = c:IRQ
				c:IRQ = {
					is_subject_of = ROOT
				}
			}
			AND = {
				owns_entire_state_region = STATE_MOSUL
				owns_entire_state_region = STATE_BAGHDAD
				owns_entire_state_region = STATE_BASRA
				owns_entire_state_region = STATE_LURISTAN
				owns_entire_state_region = STATE_KHUZESTAN
			}
		}
	}

	on_complete = {
		custom_tooltip = je_sick_man_advance
		change_variable = {
			name = sick_man_var
			add = 1
		}
		set_variable = completed_sick_man_iraq_je
	}

	invalid = {
		custom_tooltip = {
			text = finished_sick_man_tt
			has_variable = sick_man_complete
		}
	}

	inheritable = no

	weight = 5000
}

je_sick_man_economy = {
	icon = "gfx/interface/icons/event_icons/event_industry.dds"

	complete = {
		in_default = no
		any_scope_state = {
			is_incorporated = yes
			has_building = building_urban_center
			percent >= 0.75
		}
	}

	on_complete = {
		set_variable = completed_sick_man_economy_je
		custom_tooltip = je_sick_man_advance
		change_variable = {
			name = sick_man_var
			add = 1
		}
	}

	invalid = {
		custom_tooltip = {
			text = finished_sick_man_tt
			has_variable = sick_man_complete
		}
	}

	inheritable = no

	weight = 5000
}

# Literacy and Universities
je_sick_man_education = {
	icon = "gfx/interface/icons/event_icons/event_newspaper.dds"

	complete = {
		any_scope_building = {
			is_building_type = building_university
			occupancy > 0.9
			level >= 5
		}
		scope:journal_entry = {
			is_goal_complete = yes
		}
	}

	on_complete = {
		set_variable = completed_sick_man_education_je
		custom_tooltip = je_sick_man_advance
		change_variable = {
			name = sick_man_var
			add = 1
		}
	}

	current_value = {
		value = root.literacy_rate
	}

	goal_add_value = {
		value = root.literacy_rate
		add = 0.2
	}

	invalid = {
		custom_tooltip = {
			text = finished_sick_man_tt
			has_variable = sick_man_complete
		}
	}

	inheritable = no

	weight = 5000

	progressbar = yes
}

# Nationalism
je_sick_man_separatism = {
	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
		}
		highest_secession_progress < 0.5
	}

	on_complete = {
		set_variable = completed_separatism_sick_man_je
		custom_tooltip = je_sick_man_advance
		change_variable = {
			name = sick_man_var
			add = 1
		}
	}

	on_monthly_pulse = {
		effect = {
			if = {
				limit = {
					highest_secession_progress < 0.5
				}
				change_variable = {
					name = sick_man_separatist_var
					add = 1
				}
			}
		}
		random_events = {
			100 = 0
			10 = tanzimat_events.5 # Paranoia Event
		}
	}

	fail = {
		highest_secession_progress > 0.9
	}

	current_value = {
		value = var:sick_man_separatist_var
	}

	goal_add_value = {
		add = 180
	}

	invalid = {
		custom_tooltip = {
			text = finished_sick_man_tt
			has_variable = sick_man_complete
		}
	}

	inheritable = no

	weight = 5000

	progressbar = yes
}

# Army Reform
je_sick_man_army = {
	icon = "gfx/interface/icons/event_icons/event_military.dds"

	complete = {
		army_size >= 150
		has_technology_researched = napoleonic_warfare
		NOT = {
			any_scope_building = {
				is_building_type = building_barracks
				OR = {
					building_has_goods_shortage = yes
					has_active_production_method = pm_irregular_infantry
					has_active_production_method = pm_no_artillery
					has_active_production_method = pm_cannon_artillery
				}
			}
		}
	}

	on_complete = {
		set_variable = completed_sick_man_army_je
		custom_tooltip = je_sick_man_advance
		change_variable = {
			name = sick_man_var
			add = 1
		}
	}

	on_monthly_pulse = {
		events = {
			tanzimat_events.10 # Tanzimat Draft Question
		}
	}

	invalid = {
		custom_tooltip = {
			text = finished_sick_man_tt
			has_variable = sick_man_complete
		}
	}

	inheritable = no

	weight = 5000
}


# Bureaucractic Reform
je_sick_man_bureaucracy = {
	icon = "gfx/interface/icons/event_icons/event_scales.dds"

	complete = {
		NOR = { 
			has_law = law_type:law_hereditary_bureaucrats 
			has_law = law_type:law_land_based_taxation
			has_law = law_type:law_consumption_based_taxation
		}
		bureaucracy >= 0 
		approaching_bureaucracy_shortage = no
	}

	on_complete = {
		set_variable = completed_sick_man_bureaucracy_je
		custom_tooltip = je_sick_man_advance
		change_variable = {
			name = sick_man_var
			add = 1
		}
		remove_modifier = outmoded_bureaucracy
	}

	on_monthly_pulse = {
		random_events = {
			100 = 0
			10 = tanzimat_events.9 # Land registration resisted
		}
	}

	invalid = {
		custom_tooltip = {
			text = finished_sick_man_tt
			has_variable = sick_man_complete
		}
	}

	inheritable = no

	weight = 5000
}
